Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new service Kubernetes primitive to the Operator Component Framework, aligning Services with the framework’s builder/mutator/flavor patterns used by existing primitives.
Changes:
- Introduces
pkg/primitives/service(resource, builder, mutator, flavors, handlers) plus unit tests. - Adds a new shared
ServiceSpecEditorunderpkg/mutation/editors(with tests) to support typed Service mutations. - Adds a runnable example (
examples/service-primitive) and primitive documentation (docs/primitives/service.md).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/primitives/service/resource.go | Service resource wrapper + default field applicator (ClusterIP preservation). |
| pkg/primitives/service/builder.go | Fluent builder wiring mutations, flavors, handlers, and extractors. |
| pkg/primitives/service/mutator.go | Plan/apply mutator with metadata + ServiceSpec edit categories. |
| pkg/primitives/service/handlers.go | Default operational + suspension/delete-on-suspend handlers. |
| pkg/primitives/service/flavors.go | Service flavors delegating to generic flavors helpers. |
| pkg/primitives/service/*_test.go | Unit tests for builder/mutator/handlers/flavors. |
| pkg/mutation/editors/servicespec.go | New typed editor API for corev1.ServiceSpec. |
| pkg/mutation/editors/servicespec_test.go | Unit tests for ServiceSpecEditor. |
| examples/service-primitive/* | End-to-end example wiring builder + feature mutations + extraction. |
| docs/primitives/service.md | New user-facing documentation for the service primitive. |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
<!-- claude-review-cycle --> |
5094589 to
656d3c2
Compare
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
<!-- claude-review-cycle --> |
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
|
Provides typed methods for managing service ports, selectors, session affinity, traffic policies, and other ServiceSpec fields. Includes full test coverage for all editor methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the Service primitive with: - Builder with fluent API for mutations, flavors, status handlers - Mutator with plan-and-apply pattern (metadata then spec edits) - DefaultFieldApplicator preserving immutable clusterIP/clusterIPs - DefaultOperationalStatusHandler (LoadBalancer pending until ingress assigned) - DefaultDeleteOnSuspendHandler (true - Services deleted on suspend) - PreserveCurrentLabels and PreserveCurrentAnnotations flavors - Full test coverage for builder, mutator, handlers, and flavors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers building, mutations, editors, flavors, operational status, suspension behavior, data extraction, and usage guidance. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Demonstrates base construction, feature-gated mutations (version labels, metrics port), annotation preservation, operational status tracking, suspension, and data extraction with a fake client. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use non-deprecated ServiceExternalTrafficPolicy type and rename unused test parameter. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… fix doc terminology - Fix DefaultOperationalStatusHandler to verify ingress entries have an actual IP or Hostname before reporting Operational (not just non-empty slice) - Add resource_test.go covering Resource wrapper behaviors (Identity, Object, Mutate with ClusterIP preservation, ConvergingStatus, Suspend, ExtractData) - Fix inconsistent terminology in service.md (OperationPending -> Pending) - Add test case for ingress entries without IP/Hostname Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…comments, improve port matching - Preserve server-populated Status (including LoadBalancer.Ingress) in DefaultFieldApplicator so ConvergingStatus correctly detects assigned ingress addresses. - Fix misleading doc comments on WithCustomSuspendStatus, WithCustomSuspendMutation, and WithCustomSuspendDeletionDecision to accurately reflect that Services are left in place by default. - Include Protocol in unnamed port matching in EnsurePort to avoid incorrect replacement when same port number is used with different protocols (e.g., TCP/UDP). - Update README suspension description to match actual default behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace manual status assignment with generic.PreserveStatus() to align with the deployment primitive pattern and the new shared helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Initialize plans slice inline and set active pointer directly, matching the fix already applied to deployment and configmap mutators. This prevents an empty feature from being created when the generic helper in mutator_helper.go calls beginFeature(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
|
…igration The framework now uses Server-Side Apply instead of ctrl.CreateOrUpdate, eliminating the need for field applicators to merge desired state onto current state. This removes DefaultFieldApplicator, WithCustomFieldApplicator, WithFieldApplicationFlavor, the flavors.go file, and updates all tests to use the Object()-then-Mutate() pattern. Documentation is updated to remove SSA and field applicator sections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| | Step | Category | What it affects | | ||
| | ---- | ----------------- | ---------------------------------------- | | ||
| | 1 | Metadata edits | Labels and annotations on the `Service` | | ||
| | 2 | ServiceSpec edits | Ports, selectors, type, traffic policies | | ||
|
|
There was a problem hiding this comment.
The "Internal Mutation Ordering" table also starts each row with ||, which adds an unintended empty column in rendered markdown. Please fix the table syntax to use | ... | consistently.
| - **Field Flavors**: Preserving annotations that might be managed by external tools (e.g., cloud load balancer | ||
| controllers). |
There was a problem hiding this comment.
This README claims the example demonstrates "Field Flavors" (preserving externally managed annotations), but the service primitive builder/mutator exposed in this PR doesn’t include any flavor API or implementation. Either remove this bullet or add the missing flavor support so the documentation matches the code.
| - **Field Flavors**: Preserving annotations that might be managed by external tools (e.g., cloud load balancer | |
| controllers). |
| go run ./examples/replicaset-primitive/. | ||
| go run ./examples/rolebinding-primitive/. | ||
| go run ./examples/custom-resource-implementation/. | ||
| go run ./examples/service-primitive/. |
There was a problem hiding this comment.
PR description checklist says "Does not modify shared files", but this change updates the root Makefile (and also adds shared framework code under pkg/mutation/editors and docs). Please update the PR description/checklist to reflect that shared files are modified, or move these changes to a separate PR if that’s the project expectation.
| // - component.Resource: for basic identity and mutation behaviour. | ||
| // - component.Operational: for tracking whether the Service is operational. | ||
| // - component.Suspendable: for participating in the component suspension lifecycle. | ||
| // - component.DataExtractable: for exporting values after successful reconciliation. |
There was a problem hiding this comment.
The interface list in the Resource doc comment refers to component.Suspendable / component.DataExtractable, but the actual interfaces live under pkg/component/concepts (e.g., concepts.Suspendable). Please update the comment so it points to the correct package/interface names to avoid misleading API consumers.
| // - component.Resource: for basic identity and mutation behaviour. | |
| // - component.Operational: for tracking whether the Service is operational. | |
| // - component.Suspendable: for participating in the component suspension lifecycle. | |
| // - component.DataExtractable: for exporting values after successful reconciliation. | |
| // - concepts.Resource: for basic identity and mutation behaviour. | |
| // - concepts.Operational: for tracking whether the Service is operational. | |
| // - concepts.Suspendable: for participating in the component suspension lifecycle. | |
| // - concepts.DataExtractable: for exporting values after successful reconciliation. |
Implements the
serviceKubernetes resource primitive following the pattern established by the existingConfigMapandDeploymentprimitives.Summary
serviceprimitive package underpkg/primitives/service/Checklist